//
//  MeViewCell.m
//  CarLifes
//
//  Created by yu on 2017/6/22.
//  Copyright © 2017年 jpas. All rights reserved.
//

#import "MeViewCell.h"

@implementation MeViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        _lineView = [[UIView alloc] init];
//        _lineView.backgroundColor = kBackGroundLightGrayColor;
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = SYSTEM_FONT(17);
        
        _arrowImgView = [[UIImageView alloc] init];
        _arrowImgView.image = IMAGE_NAMED(@"arrow_right");
        _arrowImgView.contentMode = UIViewContentModeScaleAspectFill;
        
        _mobileLabel = [[UILabel alloc] init];
        _mobileLabel.text = @"0531-58051562";
        _mobileLabel.font = SYSTEM_FONT(15);
        _mobileLabel.textColor = kTextGrayColor;
        
        if (@available(iOS 13.0, *)) {
            UIColor *lineViewColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
                if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
                    return kBackGroundLightGrayColor;
                } else {
                    return UIColor.opaqueSeparatorColor;
                }
            }];
            _lineView.backgroundColor = lineViewColor;
            
            UIColor *titleColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
                if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
                    return kTextBlackColor;
                } else {
                    return kDarkTextColor;
                }
            }];
            
            _titleLabel.textColor = titleColor;
            
            self.contentView.backgroundColor = UIColor.secondarySystemGroupedBackgroundColor;
        } else {
            _lineView.backgroundColor = kBackGroundLightGrayColor;
            _titleLabel.textColor = kTextBlackColor;
            self.contentView.backgroundColor = UIColor.whiteColor;
        }
        
        [self.contentView sd_addSubviews:@[_lineView,_titleLabel,_arrowImgView,_mobileLabel]];
        
        _lineView.sd_layout
        .leftSpaceToView(self.contentView, 18)
        .rightSpaceToView(self.contentView, 18)
        .bottomSpaceToView(self.contentView, 0)
        .heightIs(0.5);
        
        [_titleLabel setSingleLineAutoResizeWithMaxWidth:100];
        _titleLabel.sd_layout
        .leftEqualToView(_lineView)
        .centerYEqualToView(self.contentView)
        .heightIs(20);
        
        _arrowImgView.sd_layout
        .rightEqualToView(_lineView)
        .centerYEqualToView(_titleLabel)
        .widthIs(8)
        .heightIs(14);
        
        [_mobileLabel setSingleLineAutoResizeWithMaxWidth:200];
        _mobileLabel.sd_layout
        .leftSpaceToView(_titleLabel, 15)
        .centerYEqualToView(_titleLabel)
        .heightRatioToView(_titleLabel, 1);
        
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
